
function loadDatacity_wuye() {
  
        var scrollPic_02 = new ScrollPic();
        scrollPic_02.scrollContId = "ISL_Cont_city_wuye"; //内容容器ID
        scrollPic_02.arrLeftId = "LeftArrcity_wuye"; //左箭头ID
        scrollPic_02.arrRightId = "RightArrcity_wuye"; //右箭头ID

        if (RegionUserInfoData.cities.length < 4) {
            scrollPic_02.frameWidth = 80 * RegionUserInfoData.cities.length; //显示框宽度
            scrollPic_02.pageWidth = 40 * RegionUserInfoData.cities.length; //翻页宽度
        }
        else {
            scrollPic_02.frameWidth = 340; //显示框宽度
            scrollPic_02.pageWidth = 140; //翻页宽度
        }

        scrollPic_02.speed = 20; //移动速度(单位毫秒，越小越快)
        scrollPic_02.space = 5; //每次移动像素(单位px，越大越快)
        scrollPic_02.autoPlay = false; //自动播放
        scrollPic_02.autoPlayTime = 3; //自动播放间隔时间(秒)
        //可以先判断长度，决定是否执行initialize方法
		if (RegionUserInfoData.cities.length < 4) {
            scrollPic_02.initializeLimit();  //初始化
        }
        else {
            scrollPic_02.initialize();  //初始化
        }
        	
        return;
   
}


function loadUserLocationInfo_wuye() {
//    if (cityStr_wuye == -1 ) {
//        alert("没有符合条件的数据！");
//        return;
//    } 

	if(cityStr_wuye==0||cityStr_wuye=="0")
		{
			var cityLenth = CityData.length;
		 	for (var i = 0; i < cityLenth; i++) {	              
		                
				cityStr_wuye += CityData[i].id + ",";
			}
			if(cityStr_wuye.length > 1)
				cityStr_wuye = cityStr_wuye.substring(0, cityStr_wuye.length - 1);
		}
		
    $.ajax({
        type: "get",
        url: "fetchBuildingInfoList.action",
        data: { "cityStr": cityStr_wuye, "statusStr": statusStr_wuye, "page": page_wuye, "limit": limit },
        dataType: "jsonp",
        success: function (datas) {
        	if (datas.success == "sessionOut") {
                window.location = "index.html";
                return;
            }
            clearMarker();
            showUserLocationInfo_wuye(datas);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //alert(errorThrown);
        }
    });
}


function showRegionUserInfo_wuye(data) {
    if (data.success == "true") {

        var cityLenth = data.cities.length;
        if (cityLenth > 0) {

            var inners = "";

            for (var i = 0; i < cityLenth; i++) {
                if (data.cities[i].name.length < 7)
                    inners += "<div class=box><P><span class='templink' tag='" + data.cities[i].id + "' onclick='city_wuyeClick(this)'>" + data.cities[i].name + "</span></P></div>";
                else
                    inners += "<div class=boxl><P><span class='templink' tag='" + data.cities[i].id + "' onclick='city_wuyeClick(this)'>" + data.cities[i].name + "</span></P></div>";

            }
            $("#ISL_Cont_city_wuye").html("<div id='cityCon_wuye'></div>");   
            $("#cityCon_wuye").html(inners);
            flagcity_wuye = true;
            loadDatacity_wuye();
        } 
             
         $("#city_wuyeList").find("span:first").removeClass("templink").addClass("templinkactive");
         //$("#state_wuyeList").find("span:first").removeClass("templink").addClass("templinkactive");
    }
}


function showUserLocationInfo_wuye(data) {
    if (data.success == "true") {
    	wuyeResultData = data;
    	if(data.totalSize>0)
    	{    		
   			page_wuye_totle = Math.ceil(data.totalSize/limit); 
   			
   			if (page_wuye == 1) {
	            $("#wyLeft").css("color","gray");	
        	}else{
        		$("#wyLeft").css("color","blue");	
        	}   
    		
    		if(page_wuye_totle==1){
    			$("#wyRight").css("color","gray");		
    		}else{
    			$("#wyRight").css("color","blue");		
    		}			
    		
    		if(page_wuye == page_wuye_totle){
    			$("#wyRight").css("color","gray");	
    		}
   		}
        if (data.info != undefined && data.info.length != 0) {
            var infoLenth = data.info.length;

            if (infoLenth > 0) {
            
                var inners = "";
                for (var i = 0; i < infoLenth; i++) {  
                 
                    inners += " <div id='listarea'>";
                    inners += "<div id='listareaLeft'><img src='images/build_temp_pic.gif' width='40' height='40' /></div>";
                    inners += "<div id='listareaRight'>";
                    inners += "<div id='topcontent'>";                   
                 
                    inners += "<div id='name2'><a href='javascript:detailInfo_wuye("+data.info[i].id+","+data.info[i].lat+","+data.info[i].lon+")'>" + data.info[i].name + "</a></div>";
                    inners += " <div id='type'><strong>面积:</strong>" + data.info[i].totalArea  + "</div>";
                    inners += " <div id='number'><strong>房间:</strong>" + data.info[i].roomNum + "</div>";
                    inners += " </div>  ";
                    inners += "<div id='bottomcontent'>";
                    inners += "<div id='address'>" + data.info[i].address + "</div>";
                    inners += " </div>  ";
                    inners += " </div>  ";
                    inners += " </div>  ";
                                     
                    var lat = data.info[i].lat;
                    var lon = data.info[i].lon;
                    if (lat != null && lon != null && positionInChina(lat, lon)) {

                        var point = new BMap.Point(lon, lat);    // 创建点坐标
                        if (i == 0) {
                            map.centerAndZoom(point, 13);                     // 初始化地图,设置中心点坐标和地图级别。
                        }
                        pintterArr.push(point);
                        addMarker_wuye(point, i, data.info[i]);
                    }
                }
                if (pintterArr != null && pintterArr.length > 0)
                    map.setViewport(pintterArr);

                $("#Shortlist_wuyeContent").html(inners);
            }
        }
        else {
        	$("#Shortlist_wuyeContent").html("");
//            if ($("#menulist_wuye").css("visibility") == "visible")
               // alert("没有符合条件的数据！");
        }
    }
}

	function detailInfo_wuye(wid,lat,lon){
	 if (lat != null && lon != null && positionInChina(lat, lon)) {                             
          var point = new BMap.Point(lon, lat);   
          
		 var infoLenth = wuyeResultData.info.length;
	      if (infoLenth > 0) {   
	       for (var i = 0; i < infoLenth; i++) {  
				if(wuyeResultData.info[i].id==wid)
				{
					var obj=wuyeResultData.info[i];
					var state = obj.status;
				    var stateC = "";
			       switch (state) {
			        case 1:
			             stateC = "进行中";
			             break;
			        case 2:
			             stateC = "已建";
			             break;
			        case 3:
			             stateC = "废弃";
			             break;
			       }
			       var htmlText = '       <div id="popup_kuang2">';   		         
			        htmlText += '       <div id="popup_con">';
			        htmlText += '           <div id="popup_con_left">';
			        if(obj.imgPath!=null){
			         	htmlText += '               <div id="popup_con_pic"><a href="'+obj.imgPath+'"  target=_blank><img src="'+obj.imgPath+'" width="110" height="110" /></div>';			        
			        }
			        else
			        {
			        	htmlText += '               <div id="popup_con_pic"><img src="images/build_temp_pic.gif" width="110" height="110" /></div>';			        
			        }
			        htmlText += '           </div>';
			        htmlText += '           <div id="popup_con_right">';
			        htmlText += '               <ul>';
			        htmlText += '                   <li><strong>城市</strong>：' + obj.cityName + '</li>';
			        htmlText += '                   <li><strong>地址</strong>：' + obj.address + '</li>';
			        htmlText += '                   <li><strong>状态</strong>：' + stateC + '</li>';
			        htmlText += '                   <li><strong>负责人</strong>：' + obj.userName + '</li>';
			        htmlText += '                   <li><strong>产证面积</strong>：' + obj.totalArea + '</li>';
			        htmlText += '                   <li><strong>使用面积</strong>：' + obj.realArea + '</li>';
			        htmlText += '                   <li><strong>平方单价</strong>：' + obj.squarePrice + '</li>';
			        htmlText += '                   <li><strong>年总价</strong>：' + obj.yearlyFee + '</li>';
			        htmlText += '                   <li><strong>租金</strong>：' + obj.rentFee + '</li>';
			        htmlText += '                   <li><strong>物业建成时间</strong>：' + obj.buildingDate + '</li>';
			        htmlText += '                   <li><strong>可租年限</strong>：' + obj.rentPeriod + '</li>';
			        htmlText += '                   <li><strong>产权人</strong>：' + obj.owner + '</li>';
			        htmlText += '                   <li><strong>产权人联系方式</strong>：' + obj.ownerPhone + '</li>';
			        htmlText += '                   <li><strong>描述</strong>：' + obj.description + '</li>';
			        htmlText += '               </ul>';
			        htmlText += '           </div>';
			        htmlText += '       </div>';
			        htmlText += '   </div>';
			   
			        var opts = {
			            width: 400,     // 信息窗口宽度  
			            height: 380,     // 信息窗口高度  
			            //title: "<b>"+obj.name+"</b>"  // 信息窗口标题  
			        }
			
			        var infoWindow = new BMap.InfoWindow(htmlText, opts);  // 创建信息窗口对象  
			        map.openInfoWindow(infoWindow, point);      // 打开信息窗口   
				}
			}	
		}       
               
           map.centerAndZoom(point, 17);                   
       }      
	}

function city_wuyeClick(sender) {
    var alink07 = $("#city_wuyeList").find("span");
    cityStr_wuye = "";
    alink07.each(function () {
        $(this).removeClass("templinkactive").addClass("templink");
    });
    $(sender).removeClass("templink").addClass("templinkactive");
    alink07.each(function () {
        if ($(this).attr("class") == "templinkactive") {
            cityStr_wuye = $(this).attr("tag");
        }
    });
    if (cityStr_wuye == "") {
        cityStr_wuye = 0;
        $("#city_wuyeList").find("span:first").removeClass("templink").addClass("templinkactive");
    }   
    
     page_wuye = 1; 
    loadUserLocationInfo_wuye();
}

function state_wuyeClick(sender) {
    var alink08 = $("#state_wuyeList").find("span");
    statusStr_wuye = "";
    alink08.each(function () {
        $(this).removeClass("templinkactive").addClass("templink");
    });
    $(sender).removeClass("templink").addClass("templinkactive");
    alink08.each(function () {
        if ($(this).attr("class") == "templinkactive") {
            statusStr_wuye = $(this).attr("tag");
        }
    });
    if (statusStr_wuye == "") {
        statusStr_wuye = 0;
        $("#state_wuyeList").find("span:first").removeClass("templink").addClass("templinkactive");
    }    

	 page_wuye = 1; 
    loadUserLocationInfo_wuye();
}

function previousPage_wuye() {
    if (page_wuye == 1) {
     	//alert("已是第一页！");
        return false;
    }
    map.clearOverlays();
    pintterArr = new Array();
    page_wuye = page_wuye - 1;
    if(page_wuye==1){
        	$("#wyLeft").css("color","gray");	
    }
	$("#wyRight").css("color","blue");	
    loadUserLocationInfo_wuye();
}

function nextPage_wuye() {
	if(page_wuye == page_wuye_totle){
	  	//alert("已是最后页！");
		return false;
	}
    map.clearOverlays();
    pintterArr = new Array();    
    page_wuye = page_wuye + 1;
    if(page_wuye == page_wuye_totle){
    	$("#wyRight").css("color","gray");	
    }
	$("#wyLeft").css("color","blue");		
    loadUserLocationInfo_wuye();
}


function addMarker_wuye(point, index, obj) {
    var img = "images/point_wuye.png";

    // 创建图标对象  
	var myIcon = new BMap.Icon(img, new BMap.Size(46, 46),{  	
	   offset: new BMap.Size(10, 25),  	  
	 });
	 // 创建标注对象并添加到地图  
	 var marker = new BMap.Marker(point, {icon: myIcon});
	 
    marker.addEventListener("mouseover", function () {
      var state = obj.status;
      var stateC = "";
       switch (state) {
        case 1:
             stateC = "进行中";
             break;
        case 2:
             stateC = "已建";
             break;
        case 3:
             stateC = "废弃";
             break;
       }
       var htmlText = '       <div id="popup_kuang2">';   
//        htmlText += '               <div id="closebtn"><a href="#"><img src="images/close_btn.png" width="16" height="15" /></a></div>';
         
        htmlText += '       <div id="popup_con">';
        htmlText += '           <div id="popup_con_left">';
        if(obj.imgPath!=null){
			 htmlText += '               <div id="popup_con_pic"><a href="'+obj.imgPath+'"  target=_blank><img src="'+obj.imgPath+'" width="110" height="110" /></div>';			        
		}
		else
		{
			 htmlText += '               <div id="popup_con_pic"><img src="images/build_temp_pic.gif" width="110" height="110" /></div>';			        
		} htmlText += '           </div>';
        htmlText += '           <div id="popup_con_right">';
        htmlText += '               <ul>';
        htmlText += '                   <li><strong>城市</strong>：' + obj.cityName + '</li>';
        htmlText += '                   <li><strong>地址</strong>：' + obj.address + '</li>';
        htmlText += '                   <li><strong>状态</strong>：' + stateC + '</li>';
        htmlText += '                   <li><strong>负责人</strong>：' + obj.userName + '</li>';
        htmlText += '                   <li><strong>产证面积</strong>：' + obj.totalArea + '</li>';
        htmlText += '                   <li><strong>使用面积</strong>：' + obj.realArea + '</li>';
        htmlText += '                   <li><strong>平方单价</strong>：' + obj.squarePrice + '</li>';
        htmlText += '                   <li><strong>年总价</strong>：' + obj.yearlyFee + '</li>';
        htmlText += '                   <li><strong>租金</strong>：' + obj.rentFee + '</li>';
        htmlText += '                   <li><strong>物业建成时间</strong>：' + obj.formatDate + '</li>';
        htmlText += '                   <li><strong>可租年限</strong>：' + obj.rentPeriod + '</li>';
        htmlText += '                   <li><strong>产权人</strong>：' + obj.owner + '</li>';
        htmlText += '                   <li><strong>产权人联系方式</strong>：' + obj.ownerPhone + '</li>';
        htmlText += '                   <li><strong>描述</strong>：' + obj.description + '</li>';
        htmlText += '               </ul>';
        htmlText += '           </div>';
        htmlText += '       </div>';
        htmlText += '   </div>';
      
        var opts = {
            width: 400,     // 信息窗口宽度  
            height: 380,     // 信息窗口高度  
            //title: "<b>"+obj.name+"</b>"  // 信息窗口标题  
        }

        var infoWindow = new BMap.InfoWindow(htmlText, opts);  // 创建信息窗口对象  
        map.openInfoWindow(infoWindow, point);      // 打开信息窗口   
        //	map.centerAndZoom(point,map.getZoom()); 

    });

    map.addOverlay(marker);
}


function wuyeManager2Excel() {
    if (persionStr == -1) {
        return;
    }
     $("#export3img").css("visibility", "visible");
    $.ajax({
        type: "get",
        url: "exportBuildingInfo2Excel.action",
        data: { "cityStr": cityStr_road, "statusStr": statusStr_wuye, "page": 1, "limit": limit },
        dataType: "jsonp",
        success: function (datas) {
            openwin3(datas.fileURL)
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //alert(errorThrown);
        }
    });
}

function openwin3(url) {
    $("#export3").attr("href", url);
    $("#export3img").attr("src", "images/upload.png");
}

function wuyeManagerExport() {
    $("#export3img").css("visibility", "hidden");
    $("#export3img").attr("src", "images/load.gif");
}
